Changes how strong the colors of the whole screen are: backgrounds and sprites together. 0 leaves the colors alone and 1 is the strongest, so the dark parts get darker and the bright parts get brighter. A number below 0 counts as 0 and a number above 1 counts as 1. It ends when the next room loads.
Works differently on Game Boy - The Game Boy makes the contrast with its 4 shades: greys move toward black or white in steps as the number grows, for the picture, the letters and the sprites together, to the nearest shade.
Works differently on Game Boy Color - The Game Boy Color works the contrast out for every color of the picture and the sprites when you call it; a palette swap or a fade made after the call is not changed until you call it again.
On other consoles this differs: see Side by side and How the consoles differ.
screen_contrast(amount)| Name | Type |
|---|---|
amount | real |
Nothing.
Changes how strong the colors of the whole screen are, backgrounds and sprites together. amount is a number from 0 to 1. With 0 the colors are left alone. With 1 they are pushed as far as the console's contrast goes: the dark parts get darker and the bright parts get brighter.
It sets one number for both the backgrounds and the sprites, so the room and the things in it change as one. That is what makes it good for a flash: a boss introduction raises the contrast while its WARNING word crosses the middle of the screen and lowers it again as the word leaves. Put TEXT_BAND and this together and you have that effect.
A number below 0 counts as 0, and a number above 1 counts as 1. Nothing stops the game. (The library that does the work underneath would stop a development build for a number outside the range, so Gbabel holds the number to the range first. A flash that works its number out and overshoots by a hair is therefore harmless.)
Loading a room puts the contrast back to 0, and a restart counts. A game that sets the contrast and then changes room is never left washed out with no way to know why. If you want it in the new room, call screen_contrast again there. screen_backdrop works the same way.
Nothing you can count: no sprite, no matrix and no row-by-row effect. The console works the colors out again on the next frame after the number changes. A game that never calls screen_contrast has none of this in its ROM: the compiler switches it on only when some code calls it.
It does not touch the room transition's own fades, which go on working as usual.
// Hold A to push the colours as far as they go. Let go and they go back.
if (btn_held(BTN_A)) { screen_contrast(1); } else { screen_contrast(0); }A Step event that tells the screen every frame how strong to make its colors.
// A pulse that swells and fades, three seconds from one flash to the next.
screen_contrast(wave(0, 1, 180, 0));wave(0, 1, 180, 0) goes between 0 and 1 and back every 180 frames, so the whole screen breathes.
Sets the contrast on every background palette and every sprite palette with the one number, so it costs no sprite, no matrix, no row-by-row effect and no memory worth counting: the console’s colors are worked out again once, on the frame after the number changes, and the work is done by the library underneath. The library underneath refuses a number outside 0 to 1 (a development build stops); this function holds it to the nearest end instead, so a pulse that overshoots by a hair is harmless. It does not touch the room transition’s own fades. Loading a room (a restart counts) puts it back to 0, exactly as it does for screen_backdrop, so a game that sets it and changes room is never left washed out without knowing why; call it again in the new room if you want it to carry on. A game that never calls it has none of this in its cartridge: the compiler turns it on only when some code calls it.